package pers.jsan.litheopen.utils;

public class RandomCode {

    private final static String CODES = "0123456789abcdefghijklmnopqrstuvwxyzABCDZFGHIJKLMNOPQRSTUVWXYZ";

    /**
     * 随机字符串
     *
     * @param length 随机字符串长度
     * @return String
     */
    public static String randomString(int length) {
        StringBuilder result = new StringBuilder();
        for (int i = 0; i < length; i++) {
            int rand = (int) (Math.random() * CODES.length());
            result.append(CODES.charAt(rand));
        }
        return result.toString();
    }
}
